package com.sjsoft.webservice;

import android.app.IntentService;
import android.content.Intent;

import com.sjsoft.application.chatVideoApp;
import com.sjsoft.constant.Constant;
import com.sjsoft.model.CSubCategory;
import com.sjsoft.model.IRequestItem;
import com.sjsoft.model.RequestItem;
import com.sjsoft.webservice.ServiceQueueUploadingUtil;

public class GetVideoService extends IntentService implements Constant{
	protected chatVideoApp application;
	public GetVideoService() {
		super("Download Service1");
	}
	@Override
	protected void onHandleIntent(Intent intent) {
		this.application = (chatVideoApp) getApplicationContext();
		IRequestItem item = new RequestItem();
		int nCountTab = this.application.videoByCategory.size();
		for(int i =0; i < nCountTab; i++)
		{
			CSubCategory itemTab = this.application.videoByCategory.get(i);
			if(itemTab != null)
			{
				item.getListExtend().add(itemTab.getExtendId());
			}
		}		
		
		GetVideoThread.curState = 0;
		if (GetVideoThread.state == GetVideoThread.ACTION_UPLOADING) {
			ServiceQueueUploadingVideo.pushDownloadTaskQueue(
					getApplicationContext(), item);
		} else {
			ServiceQueueUploadingVideo.pushDownloadTaskQueue(
					getApplicationContext(), item);
			ServiceQueueUploadingVideo.runDownloadQueue(getApplicationContext());
		}
	}
}
